Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache plugin modules #9031

Merged
merged 4 commits into from
Nov 20, 2023
Merged

Cache plugin modules #9031

merged 4 commits into from
Nov 20, 2023

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented Nov 8, 2023

resolves #9029

Local results:

  • Before: make integration 1377.96s user 124.94s system 834% cpu 3:00.16 total
  • After: make integration 1057.26s user 61.76s system 719% cpu 2:35.55 total

Problem

Scanning all available python modules is slow.

Solution

For the purposes of detecting dbt plugins, only do this once per process invocation and cache the result.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@peterallenwebb peterallenwebb requested a review from a team as a code owner November 8, 2023 00:12
@cla-bot cla-bot bot added the cla:yes label Nov 8, 2023
Copy link
Contributor

github-actions bot commented Nov 8, 2023

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1c9cec1) 86.66% compared to head (a323ab5) 86.61%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9031      +/-   ##
==========================================
- Coverage   86.66%   86.61%   -0.06%     
==========================================
  Files         179      179              
  Lines       26564    26569       +5     
==========================================
- Hits        23022    23013       -9     
- Misses       3542     3556      +14     
Flag Coverage Δ
integration 83.48% <100.00%> (-0.12%) ⬇️
unit 64.98% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!!!

@peterallenwebb
Copy link
Contributor Author

Python 3.8 lacks @functools.cache, so we'll have to work around.

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very neat!!

@@ -63,6 +65,17 @@ def get_manifest_artifacts(self, manifest: Manifest) -> PluginArtifacts:
raise NotImplementedError(f"get_manifest_artifacts hook not implemented for {self.name}")


@functools.cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterallenwebb Per docs, sounds like @functools.cache might just be 3.9+ syntactic sugar for @functools.lru_cache(maxsize=None), which is available on earlier versions?

@peterallenwebb peterallenwebb merged commit 9bb970e into main Nov 20, 2023
51 checks passed
@peterallenwebb peterallenwebb deleted the paw/cache-for-plugins branch November 20, 2023 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-3336] [Test Performance] Optimize the set_up_plugin_manager() function
3 participants